package com.hj.ct.adapter;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.hj.ct.R;

public class SpinnerAdapter extends BaseAdapter {

	private List<String> list = new ArrayList<String>();

	private Context context;

	public SpinnerAdapter(Context context) {
		this.context = context;
	}

	public int getCount() {
		return list.size();
	}

	public String getItem(int arg0) {
		return list.get(arg0);
	}

	public long getItemId(int arg0) {
		return arg0;
	}

	public View getView(int arg0, View convertView, ViewGroup arg2) {
		Holder holder;
		if (convertView == null) {
			holder = new Holder();
			convertView = View.inflate(context, R.layout.item_spinner_list, null);
			holder.text = (TextView) convertView.findViewById(R.id.spinner_text);
			convertView.setTag(holder);
		}
		holder = (Holder) convertView.getTag();
		holder.text.setText(list.get(arg0));
		return convertView;
	}

	public class Holder {
		public TextView text;

	}

	public List<String> getList() {
		return list;
	}

	public void setList(List<String> list) {
		if (list != null) {
			this.list = list;
		}
	}
}
